package com.kfh.ybracelet.find;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.kfh.ybracelet.R;
import com.kfh.ybracelet.base.BaseActivity;
import com.kfh.ybracelet.utils.Constant;

/**
 * 问卷调查
 * Created by Aaron on 16/5/26.
 */
public class InquireActivity extends BaseActivity {

    private WebView wv_inquire;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_inquire);

        initWidget();

    }

    private void initWidget() {

        TextView tvtitle = (TextView) findViewById(R.id.tv_title);
        tvtitle.setText(getResources().getString(R.string.inquire));

        ImageView ivleft = (ImageView) findViewById(R.id.iv_left);

        wv_inquire = (WebView) findViewById(R.id.wv_inquire);

        WebSettings settings = wv_inquire.getSettings();

        settings.setDomStorageEnabled(true);
        settings.setJavaScriptEnabled(true);

        //让webview在程序内部打开网页 而不调用系统的浏览器
        wv_inquire.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                return false;

            }
        });

        wv_inquire.loadUrl(Constant.INREQUIRE);
        wv_inquire.setWebChromeClient(new WebChromeClient());
        ivleft.setOnClickListener(this);

    }

    @Override
    public void widgetClick(View v) {

        switch (v.getId()) {

            case R.id.iv_left:
                finish();
                break;

        }

    }

    @Override
    public void onBackPressed() {

        if (wv_inquire.canGoBack()) {
            wv_inquire.goBack();
        }else {
            super.onBackPressed();
        }
    }
}
